package com.vehicle.service.imp;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.vehicle.bean.DataGridView;
import com.vehicle.bean.PageVo;
import com.vehicle.mapper.ApplyUseMapper;
import com.vehicle.mapper.CarExamineMapper;
import com.vehicle.mapper.CarMapper;
import com.vehicle.pojo.ApplyUse;
import com.vehicle.pojo.Car;
import com.vehicle.pojo.Check;
import com.vehicle.service.CarExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CarExamineServiceImpl implements CarExamineService {

    @Autowired
    private ApplyUseMapper applyUseMapper;

    @Autowired
    private CarExamineMapper carExamineMapper;

    @Autowired
    private CarMapper carMapper;

    @Override
    public DataGridView findAllApplyUseByStatus(Integer deptid, PageVo pageVo) {
        PageHelper.startPage(pageVo.getPage(),pageVo.getLimit());
        List<ApplyUse> applyUseByStatus = applyUseMapper.findApplyUseByStatus(3,deptid);
        DataGridView dataGridView = new DataGridView();
        PageInfo pageInfo = new PageInfo<>(applyUseByStatus);
        dataGridView.setCount(pageInfo.getTotal());
        dataGridView.setData(applyUseByStatus);
        return dataGridView;
    }

    @Override
    public void CheckAdd(Check check) {
        carExamineMapper.checkAdd(check);
    }

    @Override
    public Check selectCheckByApplyid(Integer applyid) {
        return carExamineMapper.selectCheckByApplyid(applyid);
    }

    @Override
    public List<Car> selectCarByLazy() {
        return carMapper.selectCarByLazy();
    }

    @Override
    public void delCheck(Integer applyid) {
        carExamineMapper.delCheck(applyid);
    }
}
